const fs = require('fs');

const path = require('path');

const cwd = process.cwd();

const defaultConf = fs.readFileSync(path.join(__dirname,'../default.conf'),'utf8').split('\r\n').filter(item=>!item.startsWith('#'));

let usrConf = null;

const hasConfigure = false

try {
    // 读取用户自己的配置文件
    usrConf = fs.readFileSync(path.join(cwd,'./autopack.conf'),'utf8');

    usrConf = usrConf ? usrConf.split('\r\n').filter(item=>!item.startsWith('#')) : null;

    hasConfigure = true;

} catch (error) {

}

// 序列化配置文件内容
function formatterConf(content){

    const obj = {}

    if(!Array.isArray(content)) return obj;

    content.forEach(item=>{

        let confItem = item.split(':');

        obj[confItem[0]] = confItem[1] || '';

    });

    return obj;
}
module.exports={
    ...Object.assign(formatterConf(defaultConf),formatterConf(usrConf)),
    hasConfigure
};